<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" import="com.tangdi.Bean.*"%>
<%@ page language="java" import="com.tangdi.Utils"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script language="javascript" type="text/javascript"
	src="My97DatePicker/WdatePicker.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.media.js"></script>
<script type="text/javascript" src="js/jquery.mediadata.js"></script>
<title>单位工资发放汇总</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript">
        //pdf预览
	    function showPDF(file_Url){
		    var x = window.screen.height;
		    var y = window.screen.width;
		    var h = 800;
		    var w = 1000;
		    var model = "title=word,resizable=yes,scrollbars=yes,height=" + h + ",width=" + w + ",status=yes,toolbar=no,menubar=no,location=no,top=" + (x-h)/2 + ",left=" + (y-w)/2;
		    var url = "";
	        pdf_url = "report_File/" + file_Url + ".pdf"; 

	        //+encodeURI(pdf_url)
		    url = "showPDFdialog.jsp?pdf_url="+ pdf_url;//弹出窗口的页面内容
		    //alert(url);
		    var oOpen = window.open(url,"adviceDetail",model);
		    oOpen.focus();
	    }
		
		function check(){
			var form = document.getElementById('gz_pay_slip');
			var year_month = form.year_month.value;
			if(year_month != ""){
			   form.action="dwGZ_FF_HZAction?type=2";
			   }
			else{
			     alert("年月不能为空");
			     return;
			     }
			}
		
		function selectAll(){ 
			var selectAllHandler = document.getElementById("selectAllHandler"); 
			var selectAll = document.getElementsByName("dms"); 
			for(i=0;i<selectAll.length;i++){
				selectAll[i].checked = selectAllHandler.checked; 
			} 
			  
			}
		
		 function printFile() {
			 var file_paths = document.getElementById("file_url_pdf").value;
			 if(file_paths == "" || file_paths.length == 0){
				 alert("打印文件路径为空");
				 return;
			 }
           $.ajax({//几个参数需要注意一下
               type: "POST",//方法类型
               contentType: "application/x-www-form-urlencoded; charset=utf-8",
              // dataType: "json",//预期服务器返回的数据类型
               url: "dwGZ_FF_HZAction" ,//url
               timeout : 10000000, //超时时间设置，单位毫秒
               data: {"type":3,"file_paths":file_paths},
               success: function (msg) {
                   if (msg == "success") {
                       alert("打印完成");
                       }else{
                       	alert(msg);
                       	}
                   }
               });
	        }
	</script>
</head>
<jsp:include page="header.jsp"></jsp:include>
<body>
	<form onSubmit="return check()" method="post" id=gz_pay_slip>
		<table>
			<tr>
				<td width="70" style="text-align:right">年月：</td>
				<td width="70"><input class="Wdate" type="text" required="true" 
					name="year_month" onfocus="WdatePicker({dateFmt:'yyyyMM'})"
					value="${year_month}" /></td>
				<td width="70"></td>
				<td width="30"><input type="submit" value="查 询" /></td>
			</tr>
		</table>
	</form>
	<%
    String year_month = (String)session.getAttribute("year_month");
    String file_Url = (String)session.getAttribute("file_Url");
    String file_Url_excel = (String)session.getAttribute("file_Url_excel");
	%>
	<table border="1" cellpadding="0" cellspacing="0" id="caseListTable">
		<% 
    if(file_Url != null){
	%>
		<tr class="oddrowcolor">
			<td width="80" align="center">日 期：</td>
			<td width="80" align="center">${year_month}</td>
			<td width="80" align="center">名 称：</td>
			<td width="300" align="left">单位工资发放汇总表</td>
			<td width="250" align="center">
				<INPUT type="button" name="inputboxbt" value="PDF预览" onclick="showPDF('<%=file_Url%>')">
				<button type="button" onclick="printFile()">打 印</button>
				<input type="hidden" id="file_url_pdf" name="file_url_pdf" value="${file_Url}.pdf" />
				<a href="${pageContext.request.contextPath}/report_File/<%=file_Url_excel%>.xls">导出Excel</a>
			</td>
		</tr>
	<% 
    }else{%>
		<p>未查到信息</p>
		<% }
   	%>
	</table>
</body>
</html>
